<?php if($error == false) {?>

<table width="1028px" style="width:1028px">
	<tbody>
		<tr>
			<td width="100%">
				<table align="center" width="100%">
					<tbody>
						<tr>
							<td valign="top" style="text-align:left; vertical-align:top" width="30%">
								<b>TESRENG FEDERAL PAINT COMPANY</b><br>
								Tel: 012 855 424 - 097 97 37 222<br>
								Email: tesreng@gmail.com
							</td>
							<td valign="top" style="text-align:center; vertical-align:top" width="70%">
								<h2 style="padding:5px; margin-bottom:10px"><?php echo $this->document->text['text_header_cashbook']?></h2>
								<div style="clear:both"></div>
								<div style="text-align:left">
									<table>
										<tr>
											<td style="text-align:center"><?php echo $this->document->text['text_date']?>: From <?php echo $search_fromdate?><?php echo $this->document->text['text_to']?><?php echo $search_todate?></td>
										</tr>
									</table>
								</div>
								<div style="clear:both"></div>
							</td>
						</tr>
					</tbody>
				</table>
				<table class="grid" style="width:1028px" align="center" cellpadding="5" cellspacing="0">
					<thead style="font-weight:bold">
						<th width="50px"><?php echo $this->document->text['text_date']?></th>
                        <th width="100px"><?php echo $this->document->text['text_vouchernol']?>:</th>
						<th width="100px">OrderNumber</th>
                        <th width="200px"><?php echo $this->document->text['text_accounttype']?></th>
						<th width="200px"><?php echo $this->document->text['text_description']?>:</th>
						<th width="100px"><?php echo $this->document->text['text_income']?></th>
						<th width="100px"><?php echo $this->document->text['text_expens']?></th>
						<th width="100px"><?php echo $this->document->text['text_moneyinstock']?></th>
					</thead>
					<tbody>
						 <tr>
					<td colspan="7" style="font-weight:bold; background:#f4f4f4"><?php echo $this->document->text['text_startperiod']?></td>
					<td class="calc" style="text-align:right; font-weight:bold; background:#f4f4f4"><?php echo $startamount?></td>
				
				</tr>
        <?php
			$index = 0;
            foreach($reports as $item)
            {
				$index += 1;
				$startamount = $startamount + $item['incomeamount'] - $item['expenseamount'];
        ?>
                    <tr>
                        <td><?php echo $this->date->formatMySQLDate($item['voucherdate'])?></td>
						<td><?php echo $item['voucherno']?></td>
						<td><?php echo $item['ordernumber']?></td>
						<td><?php echo $accounttype[$item['vouchergroup']]?></td>
						<td><?php echo $item['description']?></td>
						<td calc="calc" style="text-align:right"><?php echo $item['incomeamount']?></td>
						<td calc="calc" style="text-align:right"><?php echo $item['expenseamount']?></td>
						<td calc="calc" style="text-align:right"><?php echo $startamount?></td>
                    </tr>
        <?php
            }
        ?>
		
					<tr>
						<td colspan="7" style="font-weight:bold; background:#f4f4f4"><?php echo $this->document->text['text_endperiod']?></td>
						<td class="calc" style="text-align:right; font-weight:bold; background:#f4f4f4"><?php echo $startamount?></td>
					
					</tr>
					
					</tbody>
				</table>
				<br>
				
				
			</td>
		</tr>
	</tbody>
	
</table>


<style>
body{font-family:Arial, Helvetica, sans-serif; font-size:10pt}
table{font-size:11pt}
table th{font-weight:bold; text-align:left}
.grid th, .grid td {font-size:10pt}
.grid td{ border:1px dotted #CCCCCC}
.grid th{ text-align:center; border:1px dotted #999999}
.sign td{width:25%; text-align:center; font-weight:bold}
</style>

<script src="<?php echo DIR_JS?>jquery.js" type="text/javascript"></script>
<script>
	$(document).ready(function(){
		$(".calc").each(function(){
			num = formateNumber($(this).html().replace(/,/g,""));
			$(this).html(num);
		});
		window.print();
	});
</script>

<?php } else  {?>
<h1>Occur Error!</h1>
<?php } ?>

